// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import store from './stores'
import App from './App'
import router from './router'
import * as filters from './filters'
import * as api from './api'
import Actions from './actions'
import MyMessage from './helpers/message'
import VueWechatTitle from 'vue-wechat-title' // 更改浏览器title的插件
import Flex from '@/components/flex/Flex'
import '@/permission' // permission control
Vue.component('Flex', Flex)
import {
  Table,
  TableColumn,
  Pagination,
  Menu,
  MenuItem,
  MenuItemGroup,
  Submenu,
  Scrollbar,
  Switch,
  Checkbox,
  CheckboxGroup,
  Col,
  Input,
  Image,
  Tree,
  Select,
  Option,
  Button,
  Popover,
  Tabs,
  TabPane,
  Tag,
  Form,
  FormItem,
  RadioGroup,
  Radio,
  Collapse,
  CollapseItem,
  DatePicker,
  InputNumber,
  Dialog,
  Message,
  MessageBox,
  Loading,
  Upload,
  ColorPicker,
  Dropdown,
  DropdownMenu,
  DropdownItem,
  Cascader,
  Progress,
  Drawer,
  Carousel,
  CarouselItem,
  Calendar
} from 'element-ui'


Vue.use(VueWechatTitle)
Vue.use(Table)
Vue.use(TableColumn)
Vue.use(Pagination)
Vue.use(Menu)
Vue.use(MenuItem)
Vue.use(MenuItemGroup)
Vue.use(Submenu)
Vue.use(Scrollbar)
Vue.use(Switch)
Vue.use(Checkbox)
Vue.use(CheckboxGroup)
Vue.use(Col)
Vue.use(Input)
Vue.use(Image)
Vue.use(Tree)
Vue.use(Select)
Vue.use(Option)
Vue.use(Button)
Vue.use(Popover)
Vue.use(Tabs)
Vue.use(TabPane)
Vue.use(Tag)
Vue.use(Form)
Vue.use(FormItem)
Vue.use(RadioGroup)
Vue.use(Radio)
Vue.use(Collapse)
Vue.use(CollapseItem)
Vue.use(DatePicker)
Vue.use(InputNumber)
Vue.use(Dialog)
Vue.use(Loading)
Vue.use(Upload)
Vue.use(ColorPicker)
Vue.use(Dropdown)
Vue.use(DropdownMenu)
Vue.use(DropdownItem)
Vue.use(Cascader)
Vue.use(Progress)
Vue.use(Drawer)
Vue.use(Carousel)
Vue.use(CarouselItem)
Vue.use(Calendar)
Vue.config.productionTip = false

Vue.prototype.$http = api
Vue.prototype.$actions = Actions
Vue.prototype.$msg = Message
Vue.prototype.$message = MyMessage
Vue.prototype.$msgBox = MessageBox

// 注册filter
Object.keys(filters).forEach(k => Vue.filter(k, filters[k]))

window.eventButtonBus = new Vue()

/* eslint-disable no-new */
const vRouter = new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  data: {
    eventHub: new Vue() // global event bus
  },
  template: '<App/>'
})

Vue.use({
  vRouter
})
